<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../share/taglib.jsp" %>
<html>
<head>
<title><bean:message key="display.${buildingForm.method eq 'edit' ? 'edit' : 'add' }"/><bean:message key="info.building.name"/></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="/css/vip.css" type="text/css">
<script type="text/javascript" src="/js/jquery-1.3.1.min.js"></script>
<%@ include file="/sks/cms/page/share/validate.inc" %>
<script type="text/javascript" src="/js/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="/js/jscripts/tiny_mce/button_style/default.js"></script>
<script type="text/javascript" src="<%=basePath%>map/js/public.js"></script>
<script type="text/javascript">
<%
boolean canEdit = !StringUtil.toBoolean(request.getAttribute("sks.isReadOnly"), false);
if (canEdit) { %>
	tinyMCE.init(getDefaultButtonStyle("intro"));
<%}%>

var require = tt.vf.req;
function bodyOnLoad() {
	require.add('name');
	tt.vf.int.add("recommend");
	new tt.NRV().set(0, '++').add("lng");//'++'表示无穷大
	new tt.NRV().set(0, '++').add("lat");//'++'表示无穷大
	new tt.LV().set(0, 64).add("developer", "linkMan");
	new tt.LV().set(0, 40).add("mobile");
	new tt.LV().set(0, 200).add("address");
	${buildingForm.method eq 'edit' ? 'tt.validate();' : ''}
}
function getAreas() {
   var select = document.getElementById('topAreaId');
   var index = select.options[select.selectedIndex].value;
   $.post("/cms/house/area.do", {method:"getAreasByTopId", areaId:index},
      function (data, textStatus){
         var areaSelect = document.getElementById('areaId');
         while(areaSelect.options.length>0) {
            areaSelect.removeChild(areaSelect.options[0]);
         }
         for (var i=0; i<data.length; i++) {
            var option = document.createElement('option');
            option.innerHTML = data[i].name;
            option.value = data[i].areaId;
            areaSelect.appendChild(option);
         }
         
      }, "json");
}

function getStations() {
   var select = document.getElementById('metroId');
   var index = select.options[select.selectedIndex].value;
   $.post("/cms/house/metro.do", {method:"getStations", metroId:index},
      function (data, textStatus){
         var stationSelect = document.getElementById('metroStationId');
         while(stationSelect.options.length>0) {
        	 stationSelect.removeChild(stationSelect.options[0]);
         }
         for (var i=0; i<data.length; i++) {
            var option = document.createElement('option');
            option.innerHTML = data[i].name;
            option.value = data[i].stationId;
            stationSelect.appendChild(option);
         }
         
      }, "json");
}

function changeStatus(status) {
	if (!status) {
		return;
	}
	if(!confirm('你确定要执行该操作吗？')) {
		return;
	}
	window.location.href = "<%=basePath%>cms/house/building.do?method=changeStatus&buildingId=${buildingForm.buildingId}&status=" + status;
}

var openWindow = function(width, height){
	var url = "<%=basePath%>sks/frontpages/map/pickMap.jsp";
	doModelessDialogAction(url, width, height, "坐标拾取系统");
};
</script>
</head>
<body onload="bodyOnLoad();" bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<html:form styleId="buildingForm" action="/cms/house/building.do" method="post" onsubmit="return tt.validate();">
<html:hidden property="buildingId"/>
<html:hidden property="publishTime"/>
<html:hidden property="status"/>
<html:hidden property="type"/>
<input type="hidden" name="method" value="${buildingForm.method}">
  <table width="90%" border="0" cellspacing="2" cellpadding="3" align="center">
    <tr bgcolor="#ffbe26">
    	<td colspan="2">
    		<%@ include file="buildingMenu.inc"%>
    	</td>
    </tr>
    <c:if test="${canAudit}">
    <tr bgcolor="f5f5f5"> 
      <td colspan="2">
      <c:if test="${buildingForm.status eq 'nonePublish'}">
      	<button type="button" onclick="changeStatus('published');">发布</button>
      </c:if>
      <c:if test="${buildingForm.status eq 'published'}">
      	<button type="button" onclick="changeStatus('nonePublish');">撤销发布</button>
      	<button type="button" onclick="changeStatus('invalidate');">标识为失效</button>
      </c:if>
      <c:if test="${buildingForm.status eq 'invalidate'}">
      	<button type="button" onclick="changeStatus('nonePublish');">撤销至未发布状态</button>
      	<button type="button" onclick="changeStatus('published');">撤销至发布状态</button>
      </c:if>
      </td>
    </tr>
    </c:if>
    <tr bgcolor="f5f5f5"> 
      <td width="20%"><div align="right"><bean:message key="info.building.name"/>：</div></td>
      <td width="80%" valign="middle"><html:text disabled="<%=isReadOnly%>" property="name" size="50"/>
        <html:errors property="name"/>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td><div align="right">创建时间：</div></td>
      <td valign="middle"><fmt:formatDate value='${buildingForm.createTime}' pattern='yyyy-MM-dd HH:mm:ss' /></td>
      <input type="hidden" name="createTime" value="<fmt:formatDate value='${buildingForm.createTime}' pattern='yyyy-MM-dd HH:mm:ss' />"/>
    </tr>
    <c:if test="${buildingForm.method eq 'edit'}">
    <tr bgcolor="f5f5f5"> 
      <td><div align="right">楼盘状态：</div></td>
      <td valign="middle"><bean:message key="info.building.status.${buildingForm.status}"/>
      <c:if test="${buildingForm.status == 'published'}">
      (<fmt:formatDate value='${buildingForm.publishTime}' pattern='yyyy-MM-dd HH:mm:ss' />)
      </c:if>
      </td>
    </tr>
    </c:if>
    <!-- tr bgcolor="f5f5f5"> 
      <td><div align="right"><bean:message key="info.building.field.status"/>：</div></td>
      <td>
      	<html:select disabled="<%=isReadOnly%>" property="status">
      	</html:select>
      </td>
    </tr-->
    <tr bgcolor="f5f5f5"> 
      <td><div align="right"><bean:message key="info.area.1"/>：</div></td>
      <td>
      	<html:select disabled="<%=isReadOnly%>" property="topAreaId" styleId="topAreaId" onchange="getAreas();">
      		<html:option value=""></html:option>
      		<html:options collection="tops" property="areaId" labelProperty="name"/>
      	</html:select>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td><div align="right"><bean:message key="info.area.2"/>：</div></td>
      <td>
      	<html:select disabled="<%=isReadOnly%>" property="areaId" styleId="areaId">
      		<html:option value=""></html:option>
      		<html:options collection="lows" property="areaId" labelProperty="name"/>
      	</html:select>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td><div align="right"><bean:message key="info.metro"/>：</div></td>
      <td>
      	<html:select disabled="<%=isReadOnly%>" property="metroId" styleId="metroId" onchange="getStations();">
      		<html:option value="-"></html:option>
      		<html:options collection="ms" property="metroId" labelProperty="name"/>
      	</html:select>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td><div align="right"><bean:message key="info.metroStation"/>：</div></td>
      <td>
      	<html:select disabled="<%=isReadOnly%>" property="metroStationId" styleId="metroStationId">
      		<html:option value="-"></html:option>
      		<html:options collection="mss" property="stationId" labelProperty="name"/>
      	</html:select>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td><div align="right">经度：</div></td>
      <td valign="middle"><html:text disabled="<%=isReadOnly%>" property="lng" styleId="lng" size="50"/>
      <% if (!isReadOnly) {%><button onclick="openWindow(800, 500);">坐标拾取</button><% } %>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td><div align="right">纬度：</div></td>
      <td valign="middle"><html:text disabled="<%=isReadOnly%>" property="lat" styleId="lat" size="50"/>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td><div align="right"><bean:message key="info.building.field.recommend"/>：</div></td>
      <td valign="middle"><html:text disabled="<%=isReadOnly%>" property="recommend" size="50"/>
      (数值越大，排名越高)
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td><div align="right">开发状态：</div></td>
      <td>
      	<html:select disabled="<%=isReadOnly%>" property="developStatus">
      		<html:option value="0">未开发</html:option>
      		<html:option value="1">开发中</html:option>
      		<html:option value="2">开发完未发售</html:option>
      		<html:option value="3">出售中</html:option>
      		<html:option value="4">已售完</html:option>
      	</html:select>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td><div align="right">开发商：</div></td>
      <td valign="middle"><html:text disabled="<%=isReadOnly%>" property="developer" size="50"/>
        <html:errors property="developer"/>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td><div align="right">联系人：</div></td>
      <td valign="middle"><html:text disabled="<%=isReadOnly%>" property="linkMan" size="50"/>
        <html:errors property="linkMan"/>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td><div align="right">联系电话：</div></td>
      <td valign="middle"><html:text disabled="<%=isReadOnly%>" property="mobile" size="50"/>
        <html:errors property="mobile"/>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td><div align="right">楼盘地址：</div></td>
      <td valign="middle"><html:text disabled="<%=isReadOnly%>" property="address" size="50"/>
        <html:errors property="address"/>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td><div align="right">楼盘介绍：</div></td>
      <td>
      <% if (!isReadOnly) { %>
      <html:textarea property="intro" styleId="intro"></html:textarea>
      <% } else { %>
      ${buildingForm.intro}
      <% } %>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td colspan="2"><div align="center"> 
          <button <%=isReadOnly ? "disabled=\"disabled\"" : ""%> type="submit" class="frm_btn"><bean:message key="display.save"/></button>
      </div></td>
    </tr>
  </table>
</html:form>
<br>
</body>
</html>